package cn.iocoder.yudao.module.cms.qlink.dal.mysql;

import cn.iocoder.yudao.framework.business.basic.dao.mapper.CoreMapper;
import cn.iocoder.yudao.framework.business.basic.dao.query.CoreLambdaQueryWrapper;
import cn.iocoder.yudao.framework.common.pojo.PageResult;
import cn.iocoder.yudao.module.cms.qlink.bo.QlinkIdentifyBO;
import cn.iocoder.yudao.module.cms.qlink.dal.dataobject.QlinkDO;
import cn.iocoder.yudao.module.cms.qlink.vo.AdminQlinkPageReqVO;
import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Select;

import java.util.List;

/**
 * 快捷链接 Mapper
 *
 * @author 山野羡民（1032694760@qq.com）
 */
@Mapper
public interface QlinkMapper extends CoreMapper<QlinkDO> {

    default PageResult<QlinkDO> selectPage(AdminQlinkPageReqVO reqVO) {
        return selectPage(reqVO, new CoreLambdaQueryWrapper<QlinkDO>()
                .likeIfPresent(QlinkDO::getTitle, reqVO.getTitle())
                .eqIfPresent(QlinkDO::getIdentify, reqVO.getIdentify())
                .eqIfPresent(QlinkDO::getStatus, reqVO.getStatus())
                .betweenIfPresent(QlinkDO::getCreateTime, reqVO.getCreateTime())
                .orderByDesc(QlinkDO::getId)
                .orderByAsc(QlinkDO::getIdentify));
    }

    @Select("""
                    SELECT `value` as identify,`label` AS title
                    FROM `system_dict_data`
                    WHERE `dict_type`='cms_qlink_identify' AND `status`=0 AND `deleted`=0
                    ORDER BY `id` DESC
            """)
    List<QlinkIdentifyBO> selectAllIdentify();

}
